import { Injectable } from '@nestjs/common';
import { JwtOptionsFactory, JwtModuleOptions } from '@nestjs/jwt';
import { ConfigService } from '@/common/config/config.service';

@Injectable()
export class JwtConfig implements JwtOptionsFactory {
  constructor(private readonly config: ConfigService) {}

  async createJwtOptions(): Promise<JwtModuleOptions> {
    return {
      secret: this.config.authSecret,
      signOptions: {
        expiresIn: this.config.authTokenExpiresIn,
      },
    };
  }
}
